var back = document.querySelector('.back'),
	again = document.querySelector('.again'),
	times = document.querySelector('.time span'),
	level = document.querySelector('.level span'),
	img = document.querySelectorAll('.evaluate li');

/**
 * 获取地址栏上的get方式的参数
 * @param name        参数键名
 */
var getQueryString = function(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if(r != null) return unescape(r[2]);
	return null;
}
var url_res = {
	time: getQueryString("time"),
	level: getQueryString("level")
}
console.log(url_res);
times.innerText = url_res.time;
level.innerText = url_res.level;

//评分
if(url_res.time >= 1 && url_res.time < 10) {
	img[0].innerHTML = '<img src="img/game_over/star_solid.png"/>';
	//level.innerText = '新手';
} else if(url_res.time >= 10 && url_res.time < 20) {
	img[0].innerHTML = '<img src="img/game_over/star_solid.png"/>';
	img[1].innerHTML = '<img src="img/game_over/star_solid.png"/>';
	//level.innerText = '高手';
} else if(url_res.time >= 20 && url_res.time < 30) {
	img[0].innerHTML = '<img src="img/game_over/star_solid.png"/>';
	img[1].innerHTML = '<img src="img/game_over/star_solid.png"/>';
	img[2].innerHTML = '<img src="img/game_over/star_solid.png"/>';
	//level.innerText = '大师';
} else if(url_res.time >= 30 && url_res.time < 60) {
	img[0].innerHTML = '<img src="img/game_over/star_solid.png"/>';
	img[1].innerHTML = '<img src="img/game_over/star_solid.png"/>';
	img[2].innerHTML = '<img src="img/game_over/star_solid.png"/>';
	img[3].innerHTML = '<img src="img/game_over/star_solid.png"/>';
	//level.innerText = '至尊';
} else if(url_res.time >= 60) {
	img[0].innerHTML = '<img src="img/game_over/star_solid.png"/>';
	img[1].innerHTML = '<img src="img/game_over/star_solid.png"/>';
	img[2].innerHTML = '<img src="img/game_over/star_solid.png"/>';
	img[3].innerHTML = '<img src="img/game_over/star_solid.png"/>';
	img[4].innerHTML = '<img src="img/game_over/star_solid.png"/>';
	//level.innerText = '无敌';
}

//再玩一次
again.addEventListener('click', function() {
	window.location.href = 'game.html';
});

//返回首页
back.addEventListener('click', function() {
	window.location.href = 'index.html';
});

//获取地址问号后面的所有参数
//location.search.replace('?', '');